package com.epalmpay.service.weixin;

import java.text.ParseException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;

import javax.servlet.http.HttpServletRequest;

import com.epalmpay.exception.ApplicationException;
import com.epalmpay.entity.Member;
import com.epalmpay.entity.PrePurchaseActivity;
import com.epalmpay.entity.TradeOffline;
import com.epalmpay.entity.YsOilcardOrder;
import com.epalmpay.util.Response;
import com.github.binarywang.wxpay.bean.result.WxPayOrderNotifyResult;


/**
 * Created by wzq on 2017/7/2.
 */
public interface IWxApiWalletService {
    //喜欢商户列表
	public Map<String, Object> getYourLikeShopList( String memberId, String user_longitude, String user_latitude,
                                                     Integer pageNo, Integer pageSize) throws Exception;
    //参与活动门店列表
    public Map<String, Object> getActivityShopList( String activityId, String user_longitude, String user_latitude) throws Exception;

    /**
     * 微信支付充值
     * @param memberId
     * @param recharge_money
     * @param recharge_type
     * @param mchCreateIp
     * @param orgOrderNum
     * @return
     * @throws ApplicationException
     */
    public Map<String, Object> updateWeixinPay(String memberId, String recharge_money, Integer recharge_type,String mchCreateIp) throws ApplicationException;
    
    
    //微信支付消费
    public Response updateWeixinPayConsumption(String memberId, String recharge_money,String mchCreateIp,String orgOrderNum,String homeUrl,String notifyUrl) throws ApplicationException;
    
    /**
     * 台卡支付优惠券列表
     * @param orderNo
     * @param transResult
     * @return
     * @throws ApplicationException
     */
    public Map<String, Object> couponList(String deskcardCode,String deskcardId,String phone,Integer tranAmt,Integer nooffertranAmt) throws ApplicationException, ParseException;
    
    /**
     *  实际付款金额
     * @param deskcardCode //台卡编号
     * @param deskcardId  台卡ID
     * @param phone
     * @param tranAmt  订单总金额
     * @param nooffertranAmt
     * @param couponUserId
     * @return
     * @throws ApplicationException
     */
    public Response calActualMoney(String deskcardCode,String deskcardId,String phone,Integer tranAmt,Integer nooffertranAmt,
    		String couponCodeStrs,Integer bonusAmount) throws ApplicationException;
    
    //获取积分可用值
    public Response selectBonus(String deskcardCode,String deskcardId,String phone,Integer tranAmt,Integer nooffertranAmt) throws ApplicationException;
    
    /**
	 * 微信台卡支付
	 * 
	 * @param tranAmt
	 *            订单总金额
	 * @param actualTranAmt
	 *            订单实际付款金额
	 * @param nooffertranAmt
	 *            不参与优惠后计算金额
	 *
	 *
	 * @param bonusAmount
	 *            积分数量
	 */
    public Response updateTkWxPay(Integer tranAmt, String mchCreateIp, String phone, String notifyUrl, String deskcardId, String remark,String deskcardCode,String openId,
    		Integer actualTranAmt,Integer nooffertranAmt,String couponUserId,Integer bonusAmount,String rootHomeUrl,String frontUrl) throws ApplicationException;
    
    /**
     * 台卡obd微信支付
     * @param orderId
     * @param realAmount
     * @param remark
     * @param openId
     * @return
     * @throws ApplicationException
     */
     public Response updateObdWxPay(String orderId,Integer realAmount, String remark,String openId,String mchCreateIp,String notifyUrl) throws ApplicationException;
     
     /**
      * 台卡obd支付宝支付
      * @param orderId
      * @param realAmount
      * @param remark
      * @return
      * @throws ApplicationException
      */
     public Response updateObdAliPay(String orderId,Integer realAmount, String remark,String mchCreateIp,String notifyUrl) throws ApplicationException;
    
    /**
     * 
     * @param tranAmt  订单总金额  
     * @param mchCreateIp
     * @param phone
     * @param notifyUrl
     * @param fyMerchantCD
     * @param remark
     * @param termId
     * @param openId
     * @param actualTranAmt  订单实际付款金额
     * @return
     * @throws ApplicationException
     */
    public Response updateTkYcgWxPay(Integer tranAmt, String mchCreateIp, String phone, String notifyUrl, String deskcardId, String remark,String deskcardCode,String openId,
    		Integer actualTranAmt) throws ApplicationException;
    
    
     //台卡支付宝支付
    public Response updateTkAliPay(Integer tranAmt, String mchCreateIp, String phone, String notifyUrl, String deskcardId, String remark,String deskcardCode,
    		Integer actualTranAmt,Integer nooffertranAmt,String couponUserId,Integer bonusAmount,String rootHomeUrl) throws ApplicationException;
    
    //台卡支付宝预采购支付
    public Response updateTkYcgAliPay(Integer tranAmt, String mchCreateIp, String phone, String notifyUrl, String deskcardId, String remark,String deskcardCode,
    		Integer actualTranAmt) throws ApplicationException;
    
    /**
     * 普通充值-无赠送
     * @param orderNo
     * @param transResult
     * @param rootHomeUrl
     * @return
     * @throws ApplicationException
     */
    public Boolean updateRechargeOrderState(String orderNo,String transResult,String rootHomeUrl) throws ApplicationException;
    
    
    /**
     * app充值
     * @param orderNo
     * @param transResult
     * @return
     * @throws ApplicationException
     */
    public Boolean updateAppRechargeOrderState(String orderNo,String transResult) throws ApplicationException;
    
    
    /**
     * 支付成功-充值送
     * @param orderNo
     * @param transResult
     * @return
     * @throws ApplicationException
     */
    public Boolean updateSendOrderState(String orderNo,String transResult,String rootHomeUrl) throws ApplicationException;
    
    
    /**
     * 台卡支付成功修改订单状态
     * @param outOrderNum 订单号
     * @param orderNo   支付机构订单号
     * @param transResult
     * @param homeRootUrl
     * @return
     * @throws ApplicationException
     */
    public TradeOffline updateTkOrderState(String outOrderNum,String orderNo,String transResult,String homeRootUrl) throws ApplicationException;
    
    /**
     * 处理预采购
     * @param outOrderNum
     * @param orderNo
     * @param transResult
     * @return
     * @throws ApplicationException
     */
    public TradeOffline updateYcgOrderState(String outOrderNum,String orderNo,String transResult,String homeRootUrl) throws ApplicationException;
    /**
     * obd台卡交易回调
     * @param orderNo
     * @param transResult
     * @return
     * @throws ApplicationException
     */
    public TradeOffline updateObdOrderState(String orderNo,String transResult) throws ApplicationException;
    
    /**
     * app消费成功修改订单状态
     * @param orderNo
     * @param transResult
     * @return
     * @throws ApplicationException
     */
    public Boolean updateGoodsOrderState(String orderNo,String transResult) throws ApplicationException;
    
    /**
     * 微信商城商品
     * @param orderNo
     * @param transResult
     * @return
     * @throws ApplicationException
     */
    public Boolean updateMallGoodsOrderState(String orderNo,String transResult,String rootHomeUrl) throws ApplicationException;
    /**
     * 服务商品订单信息
     * @param orderNo
     * @param transResult
     * @param rootHomeUrl
     * @return
     * @throws ApplicationException
     */
    public Boolean updateServiceGoodsOrderState(String orderNo, String transResult,String rootHomeUrl) throws ApplicationException ;
    
    //钱包订单回调
    public TradeOffline updatewalletOrderState(String orderNo,String respCode) throws ApplicationException;
    
    
    public Boolean updateOrderQueryNotify() throws ApplicationException;
    
    
    //支付宝充值订单状态修改
    public Boolean updateOfflineAliPay(HashMap<String, String> params,String orderNo,Boolean flag) throws ApplicationException;
    
    
    //支付宝订单状态修改
    public Boolean updateGoodsOfflineAliPay(HashMap<String, String> params,String orderNo,Boolean flag) throws ApplicationException;
    
    
    //获取微信回调参数及签名校验
    public WxPayOrderNotifyResult  WxPayResult(HttpServletRequest request) throws ApplicationException;
    
    
    //微信订单状态修改
    public Boolean updateOfflineWxPay(WxPayOrderNotifyResult result) throws ApplicationException;
    
    //微信订单消费状态修改
    public Boolean updateGoodsOfflineWxPay(WxPayOrderNotifyResult result) throws ApplicationException;
    
    
    /**
     * 给云流发送推送信息
     * @param outTradeNo  订单号
     * @param messageType    UserAuthApi中定义的消息类型
     * @return
     * @throws Exception
     */
    public Boolean updatefinishSendMessage(String outTradeNo,String messageType) throws Exception;
    
    /**
     * 完成油卡充值通知
     * @param outTradeNo
     * @return
     * @throws Exception
     */
    public Boolean finishSendYKSuccessMessage( YsOilcardOrder oilcardOrder) throws Exception;
    
    /**
     * 消费购买通知
     * @param outTradeNo  交易订单号
     * @param consumptionType  消费说明
     * @return
     * @throws Exception
     */
    public Boolean finishBuySendMessage(String outTradeNo ,String consumptionType) throws Exception;
    
    
    /**
     * 消费购买通知
     * @param tradeOrderId  交易记录Id
     * @param consumptionType  消费说明
     * @return
     * @throws Exception
     */
    public Boolean finishBuySendMessage(Long tradeOrderId ,String consumptionType) throws Exception;
    
    /**
     * 删除线上订单 
     * @param memberId 会员编号
     * @param goodsId  商品编号
     * @param goodsPrice 商品价格
     * @param amount     商品数量
     * @return
     * @throws ApplicationException
     */
    public Map<String, Object> updateWalletpaydisplay(Long memberId, String goodsId, String goodsPrice,String amount,Integer bonus, String couponSns) throws ApplicationException;
    
    //订单支付
    public Map<String, Object> updateWalletpaySubmit(String memberId,String orderId,String payType,String payPwd,String homeRootUrl) throws ApplicationException;

    //app提现回调
    
    public Boolean updateWithDrawNotify(String orderNo,String transResult) throws ApplicationException;
    
    /**
     * 微信提现回调
     * @param orderNo
     * @return
     * @throws ApplicationException
     */
    public Boolean updateWxWithDrawNotify(String orderNo,String transResult,String homeRootUrl) throws ApplicationException;
    
    
    /**
     * 系统提现回调
     * @param orderNo
     * @param transResult
     * @param homeRootUrl
     * @return
     * @throws ApplicationException
     */
    public Boolean updateSySWithDrawNotify(String orderNo,String transResult) throws ApplicationException;
    
    /**
     * 支付宝签名校验
     * @param params
     * @param out_trade_no
     * @return
     */
    boolean verfyAliPay(HashMap<String, String> params, String out_trade_no);
   
	
    public  Member selectMemberInfo(Long groupId,String phone,String openId);
	/**
	 * 
	 * @param deskcardCode
	 * @param deskcardId
	 * @return
	 */
	public PrePurchaseActivity findPrePurchaseActivity(String deskcardCode, String deskcardId);

    public Map<String, Object> getServiceOrderDetailByOrderId(String groupId, String openId,String memberId, String orderId) throws Exception;
    
    public TradeOffline findOrderId(String orderId,Integer status) throws Exception;

    public Map<String, Object> getBonusInfo(String groupId, String openId,String memberId) throws Exception;
    public Map<String, Object> getBonusInfoDetail(String groupId,String openId,String memberId,String startDate,String endDate,Integer pageNo,Integer pageSize) throws Exception;
	
   /**
    * 
    * @param tranAmt
    * @param mchCreateIp
    * @param phone
    * @param notifyUrl
    * @param deskcardId
    * @param payPwd
    * @param deskcardCode
    * @param payPwd
    * @param actualTranAmt
    * @param nooffertranAmt
    * @param couponCodes
    * @param bonusAmount
    * @return
    */
    public Response updateWalletPay(Integer tranAmt, String mchCreateIp, String phone, String notifyUrl, String deskcardId, String remark, String deskcardCode,
			String payPwd, Integer actualTranAmt, Integer nooffertranAmt, String couponCodes, Integer bonusAmount,String rootHomeUrl) throws ApplicationException, ExecutionException, InterruptedException;
	
   /***
    *  钱包预采购支付
    * @param tranAmt
    * @param mchCreateIp
    * @param phone
    * @param notifyUrl
    * @param deskcardId
    * @param string
    * @param deskcardCode
    * @param payPwd
    * @param actualTranAmt
    * @return
    */
    public Response updateWalletYcgPay(Integer tranAmt, String mchCreateIp, String phone, String notifyUrl, String deskcardId, String string,
			String deskcardCode, String payPwd , Integer actualTranAmt) throws ApplicationException ;
    
    /**
     * 用户与门店的  由于未支付 的 锁定的积分 和优惠券
     * @param phone
     * @param deskcardId
     * @param deskcardCode
     */
     public void checkUserShopOrderStatus(String phone, String deskcardId, String deskcardCode);

     Map<String,Object> getBonusRule(String groupId, String openId) throws ApplicationException;
    
    
    public Response updatefyScanCodePay(String authCode,Integer realAmount,String groupId,String mchCreateIp,String notifyUrl) throws ApplicationException;
    
    
    public Response updatefyScanCodeQuery(String orderId) throws ApplicationException;

    /**
     *  洗衣机钱包支付
     * @param tranAmt
     * @param mchCreateIp
     * @param phone
     * @param notifyUrl
     * @param deskcardId
     * @param payPwd
     * @param deskcardCode
     * @param payPwd
     * @param actualTranAmt
     * @param nooffertranAmt
     * @param couponCodes
     * @param bonusAmount
     * @return
     */
    //public Response updateXyjWalletPay(Integer tranAmt, String mchCreateIp, String phone, String notifyUrl, String shortId, String string, String machineCode,
      //                              String payPwd, Integer actualTranAmt, Integer nooffertranAmt, String couponCodes, Integer bonusAmount,String rootHomeUrl) throws ApplicationException ;
    
    
    
    /**
     * 洗衣机微信支付
     * @param tranAmt
     * @param mchCreateIp
     * @param phone
     * @param notifyUrl
     * @param shortId  洗衣机缩写ID
     * @param remark
     * @param boardid  洗衣机编号
     * @param openId
     * @param actualTranAmt
     * @param nooffertranAmt
     * @param couponCodes
     * @param bonusAmount
     * @param rootHomeUrl
     * @return
     * @throws ApplicationException
     */
    public Response updateXyjTkPay(Integer tranAmt, String mchCreateIp, String phone, String notifyUrl, String shortId, String remark, String boardid,
			String openId, Integer actualTranAmt, Integer nooffertranAmt, String couponCodes, Integer bonusAmount,String rootHomeUrl, Integer washtype) throws ApplicationException;
    
    
    
    /**
     * 洗衣机钱包支付
     * @param tranAmt
     * @param mchCreateIp
     * @param phone
     * @param notifyUrl
     * @param shortId  洗衣机缩写ID
     * @param remark
     * @param boardid  洗衣机编号
     * @param payPwd
     * @param actualTranAmt
     * @param nooffertranAmt
     * @param couponCodes
     * @param bonusAmount
     * @param rootHomeUrl
     * @return
     * @throws ApplicationException
     */
    public Response updateXyjWalletPay(Integer tranAmt, String mchCreateIp, String phone, String notifyUrl, String shortId, String remark, String boardid,
			String payPwd, Integer actualTranAmt, Integer nooffertranAmt, String couponCodes, Integer bonusAmount,String rootHomeUrl, Integer washtype) throws ApplicationException ;
    
    /**
     * 用户与门店的  由于未支付 的 锁定的积分 和优惠券
     * @param phone
     * @param machineCode
     */
    public void checkXyjUserShopOrderStatus(String phone, String shortId);

}
